# -*- coding: utf-8 -*-

from django import forms
from django.contrib import admin
from models import *
from settings import STATIC_ROOT, VERSION
import os, sys


def geticon(obj):
	return '<img src="/static/png/%s" style="height: 16px;">' % os.path.basename(obj.icon)
geticon.short_description = 'Icon'
geticon.allow_tags = True

def getcolor(obj):
	return '<div style="background: %s; padding: 4px;">%s</div>' % (obj.color,obj.color)
getcolor.short_description = 'Color'
getcolor.allow_tags = True
def get_cat_icon(obj):
	return '<img src="/static/png/%s" style="height: 16px;">' % os.path.basename(obj.category.icon)
get_cat_icon.short_description = 'Icon'
get_cat_icon.allow_tags = True

class	SimpleTodoAdmin(admin.ModelAdmin):
	list_display	= ('title','content','exist','done','priority', get_cat_icon, 'user', 'datetime','till_date')

admin.site.register(SimpleTodo,		SimpleTodoAdmin)

class	CategoryAdmin(admin.ModelAdmin):
	list_display	= ('title',geticon,getcolor)

admin.site.register(Category,		CategoryAdmin)

class	LinkAdmin(admin.ModelAdmin):
	list_display	= ('title','content','alias','exist', get_cat_icon, 'user', 'datetime')

admin.site.register(Link,		LinkAdmin)

class	NoteAdmin(admin.ModelAdmin):
	list_display	= ('title','exist', get_cat_icon, 'user', 'datetime')

admin.site.register(Note,		NoteAdmin)
